
/*
 * panFamiliares.java
 *
 * Created on 14 de mayo de 2007, 0:18
 */

package legajopersonal;

import sistemarrhh.SistemaRRHH;

import utiles.Utiles_Varios;
/**
 *
 * @author  Administrador
 */
public class jPErrores extends Panel_Legajo {
    
    /** Creates new form panFamiliares */
    public jPErrores() {
        initComponents();        
        this.sinGUI = false;                
    }    
    public jPErrores(String cade){
        this.sinGUI = true;        
    }
    public void Nemonics(){        
        this.btnImprimir.setMnemonic('I');        
        this.btnSalir.setMnemonic('S');
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tabla = new javax.swing.JTable();
        btnImprimir = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tabla);

        btnImprimir.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/print.gif"))); // NOI18N
        btnImprimir.setText("Imprimir");
        btnImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImprimirActionPerformed(evt);
            }
        });

        btnSalir.setFont(new java.awt.Font("Tahoma", 1, 11));
        btnSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/fife/plaf/Office2003/closeall.gif"))); // NOI18N
        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(315, 315, 315)
                        .addComponent(btnImprimir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnSalir)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnImprimir)
                    .addComponent(btnSalir))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed
// TODO add your handling code here:
      this.botonImprimir(this.tabla,this.banImprimir, this.cabImprimir, this.pieImprimir);
    }//GEN-LAST:event_btnImprimirActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
// TODO add your handling code here:        
        try{
            this.cerrarPadre();     
            //this.CerrarConexionRMI();            
        }catch(Exception e){
            System.out.println("Error al cerrar conexiones");
        }       
            this.botonSalir();
    }//GEN-LAST:event_btnSalirActionPerformed
    public void botonNuevo(){
    }
    public void botonSalir(){        
    }
    public void botonActualizar(){
    }
    public void botonEliminar(){
    }
    public void botonDetalles(){
    }
    public void botonImprimir( ){
        try{
            tabla.print();
        }catch(Exception e){            
        }        
    }
    public void botonImprimir( javax.swing.JTable jtb, boolean ban, String cabe,String piepag ){
        try{
            utiles.imprimir.tabla(jtb ,ban ,cabe,piepag);
        }catch(Exception e){
            mensaje("No se pudo completar la impresion\n"+e.toString());
        }
        
    }    
    public boolean getbanImprimir(){
        return banImprimir;        
    }
    public String getCabImprimir(){
        return cabImprimir;
    }
    public String getPieImprimir(){
        return pieImprimir;
    }
    
    public void setParametrosImprimir( boolean ban, String cabe,String piepag ){        
        //this.tablaImprimir = jtb;
        this.banImprimir = ban;
        this.cabImprimir = cabe;
        this.pieImprimir = piepag;
    }
    public void centrarceldas(javax.swing.JTable table){
        new utiles.Utiles_Varios().centraCeldasTabla(table);
    }
    public void setDatosReportes(String dir){        
        direcc = System.getProperty("user.dir")+"\\Reportes_Legajo\\";                                        
        direcc+=dir;
    }    
    public void inicializarTabla(String cabe[]){
        this.cabe = cabe;
        this.tabla.setModel(new javax.swing.table.DefaultTableModel(
                             new Object [][] {
                                /*{null, null, null, null}*/
                                },
                            cabe                
                        ){
                            public boolean isCellEditable(int row, int col) {
                                return editable[col];                                
                            }
                        }
          );        
    }              
    public void inicializarTabla(String cabe[],javax.swing.JTable table){
        table.setModel(new javax.swing.table.DefaultTableModel(
                             new Object [][] {
                                /*{null, null, null, null}*/
                                },
                            cabe                
                        ){
                            public boolean isCellEditable(int row, int col) {
                                return editable[col];                                
                            }
                        }
          );        
    }        
   public void CerrarDialogo(){
       int opc = javax.swing.JOptionPane.showConfirmDialog(this,"Esta seguro de Salir","Salir",javax.swing.JOptionPane.YES_NO_OPTION);
       if(opc==javax.swing.JOptionPane.YES_OPTION){
           this.cerrarPadre();
       }
    }    
    public void cargarTablaRemota(String consulta,String []cabe){
        this.consulta = consulta;
        this.tabla = tabla;
        this.cabe = cabe;
        try{
            final String [][]estudios = this.getCliRMI().getObjetoCLIRMI().getTabla(consulta,this.getID());
            if(estudios.length<=0){
                mensaje("No existen registros para Mostrar");                
                 tabla.setModel(new javax.swing.table.DefaultTableModel(
                         new Object [][] {
                            /*{null, null, null, null}*/
                            },
                          cabe
                    ));
            }
            else{
                 javax.swing.table.DefaultTableModel modelo = new javax.swing.table.DefaultTableModel(
                    estudios ,                   
                     cabe
                    ) {
                    public Object getValueAt(int row, int col) {
                        return estudios[row][col];
                    }
                };
                tabla.setModel(modelo);                   
                tabla.setRowSelectionInterval(0,0);                  
            }                           
        }catch(Exception e ){
            this.mensaje("Error al Cargar Tabla Remota "+e.getMessage());            
        }
    } 
     public void cargarTablaRemota(String []cabe,String [][]datos){                
        this.cabe = cabe;
        try{
            final String [][]data = datos;
            if(data.length<=0){
                mensaje("No existen registros para Mostrar");                
                 tabla.setModel(new javax.swing.table.DefaultTableModel(
                         new Object [][] {                     
                            },
                          cabe
                    ));
            }
            else{
                System.out.println("Tiene elementos");
                utiles.modelTabla modelo1 = new utiles.modelTabla(datos, cabe);
                /*javax.swing.table.DefaultTableModel modelo = new javax.swing.table.DefaultTableModel(
                    data ,                   
                     cabe
                    ) {
                    public Object getValueAt(int row, int col) {
                        return data[row][col];
                    }
                };*/
                tabla.setModel(modelo1);                   
                tabla.setRowSelectionInterval(0,0);                  
            }                           
        }catch(Exception e ){
            this.mensaje("Error al Cargar Tabla Remota "+e.getMessage());            
        }
    } 
    public void cargarTablaRemota(String consulta,String []cabe,javax.swing.JTable table){
        this.consulta = consulta;
        this.tabla = table;
        this.cabe = cabe;
        try{
            System.out.println("Esta es la consulta:"+consulta);
            final String [][]estudios = this.getCliRMI().getObjetoCLIRMI().getTabla(consulta,this.getID());
            if(estudios.length<=0){
                mensaje("No existen registros para Mostrar");                
                 table.setModel(new javax.swing.table.DefaultTableModel(
                         new Object [][] {                            
                            },
                          cabe
                    ));
            }
            else{
                 javax.swing.table.DefaultTableModel modelo = new javax.swing.table.DefaultTableModel(
                    estudios ,                   
                     cabe
                    ) {
                    public Object getValueAt(int row, int col) {
                        return estudios[row][col];
                    }
                };
                table.setModel(modelo);                   
                table.setRowSelectionInterval(0,0);                  
            }                           
        }catch(Exception e ){
            this.mensaje("Error al Cargar Tabla Remota "+e.getMessage());            
        }
    }
    
    public void setBotonesText(boolean ban){
        this.btnImprimir.setVisible(ban);
        //this.btnReportes.setVisible(ban);        
    }       
    public void setBotonImprimir(boolean ban){
        this.btnImprimir.setEnabled(ban);
    }    
    public void RestablecerTabla(){
         try{
             this.cargarTablaRemota(consulta,cabe);
         }catch(Exception e){
             System.out.println("Error al refrescar la tabla: " + e.getMessage());
         }
     }
    public void RestablecerTabla(javax.swing.JTable table){
         try{
             this.cargarTablaRemota(consulta,cabe,table);
         }catch(Exception e){
             System.out.println("Error al refrescar la tabla: "+ e.getMessage());
         }
     }
    public javax.swing.JTable retornarTable(){
        return tabla;
    }         
    public void RestablecerTablaRemota(){
         try{             
             cargarTablaRemota(consulta,cabe);             
         }catch(Exception e){
             System.out.println("Error al refrescar la tabla");
         }
     }
    
    public String getCodTabla(){
        String cad="";
        if(tabla.getRowCount()>0){
            int fila = tabla.getSelectedRow();
            if(fila >-1){
                cad = (String)tabla.getValueAt(fila,0);
            }            
        }
        return cad.trim();            
    }
    public String getDatoTabla(int columna,javax.swing.JTable table){
        String cad="";
        if(table.getRowCount()>0){
            int fila = table.getSelectedRow();
            if(fila >-1){
                cad = (String)table.getValueAt(fila,columna);
            }            
        }
        return cad.trim();            
    }
    public String getCodTabla(javax.swing.JTable table){
        String cad="";
        if(table.getRowCount()>0){
            int fila = table.getSelectedRow();
            if(fila >-1){
                cad = (String)table.getValueAt(fila,0);
            }            
        }
        return cad.trim();            
    }       
    public void setCabe(String[]cabe){
        this.cabe = cabe;        
    }
    public void setEditable(boolean []editable){
        this.editable = editable;
        
    }    
    public String[] getCabe(){
        return this.cabe;
    }
    public boolean []setEditable(){
        return this.editable;        
    }
    public javax.swing.JTable getTabla(){
        return this.tabla ;
    }
    public void setCambios(boolean ban){
        this.cambios = ban;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnSalir;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabla;
    // End of variables declaration//GEN-END:variables
    javax.swing.JComboBox combo;
    String valores[][],busca[];    
    public Util_Francisco.JBDTable tbModel;        
    utiles.ScrollableTableModel modelo;
    String DNI_Estudios;
    String cod_est;
    utiles.conexionRmiJdbc conec;
    java.sql.ResultSet rs;
    String ip, puerto, dns, us,con;
    String est_Act="";
    String consulta;    
    String []cabe;
    boolean []editable;
    boolean sinGUI = false;    
    String direcc;    
    boolean cambios = true;
    String cabImprimir = "", pieImprimir = "";
    boolean banImprimir = false;
}